package com.duying.ht.manager;

import java.util.HashMap;
import java.util.Map;

import com.busi.framework.base.PageSupport;
import com.duying.ht.HtCC;
import com.duying.ht.HtCommonManager;
import com.duying.ht.model.HtMain;

public class HtMainManager extends HtCommonManager{

	
	public PageSupport getPageForDuban(Integer pageNo){
		String hql = "from HtMain hm where hm.auditing <= " + HtCC.ht_5 + " order by hm.change_time desc";
		PageSupport apage = this.baseDao.findPageByHql(hql, pageNo);
		return apage;
	}
	
	public PageSupport getPageByAuditing(Map map , Integer pageNo){
		
		String hql = "from HtMain hm where 1=1";
		Map params = new HashMap();
		if(map != null){
			Object objAuditing = map.get("auditing");
			if(objAuditing != null){
				Integer auditing = (Integer)objAuditing;
				hql += " and hm.auditing =:auditing ";
				params.put("auditing", auditing);
			}
			
			Object objDeptId = map.get("deptId");
			if(objDeptId != null){
				Integer deptId = (Integer)objDeptId;
				hql += " and hm.next_huiqian_deptid =:deptId ";
				params.put("deptId", deptId);
			}
			
			Object objSongshenUserId = map.get("songshen_user_id");
			if(objSongshenUserId != null){
				Integer songshenUserId = (Integer)objSongshenUserId;
				hql += " and hm.songshen_user_id =:songshen_user_id";
				params.put("songshen_user_id", songshenUserId);
			}
		}
		hql += " order by hm.songshen_date desc";
		PageSupport apage = this.baseDao.findPageByHql(hql, pageNo, map);
		return apage;
	}
	
	
	public HtMain getById(String id){
		System.out.println(id);
		return this.htMainDao.getById(id);
	}
}
